# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=soqt
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.6.0
pkgrel=1
pkgdesc="A Qt Gui-toolkit binding for Coin"
arch=('any')
url="https://github.com/coin3d/soqt"
license=('custom:coin')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-coin"
         "${MINGW_PACKAGE_PREFIX}-qt5")
options=('!strip' 'staticlibs' '!buildflags')
source=("soqt-SoQt-${pkgver}.tar.gz::https://github.com/coin3d/soqt/archive/SoQt-${pkgver}.tar.gz"
        "sogui-soqt-${pkgver//./_}.tar.gz::https://github.com/coin3d/sogui/archive/soqt-${pkgver//./_}.tar.gz"
        "soanydata-soanydata-1_1_0.tar.gz::https://github.com/coin3d/soanydata/archive/soanydata-1_1_0.tar.gz"
        'soqt-1.6.0-use-cpack-off.patch'
        'soqt-1.6.0-build-tests-on.patch'
        'soqt-x11-win32.patch')
sha256sums=('80bbee01089af754380c48ea435008ea93465149999a545741c410efe8e9bef9'
            'ec94bad2795d66b61146eafaeef47c592ad14a3213a0c7eca3fb0866c0825150'
            '203de840b99b3641ab27462be9d493a63d2bc9f03530ae58230f2e848e9ce25b'
            '120aca5ebce169dacfa948a8715278d11eb5d8620e98bf6222016600b8bb75f2'
            '3ba27ec30e3f056f09e2c5e28e5a0694765122740d0802a0c03068b97810cc47'
            'ebb56b4720af6f7dfee17890d5d7655b1da8fe8ac870b4750ee0d30431dc02c8')

prepare() {
  cd "${srcdir}/soqt-SoQt-${pkgver}"
  patch -p1 -i "${srcdir}/soqt-1.6.0-use-cpack-off.patch"
  patch -p1 -i "${srcdir}/soqt-1.6.0-build-tests-on.patch"
  patch -p1 -i "${srcdir}/soqt-x11-win32.patch"
  [[ -d data ]] || cp -r "${srcdir}/soanydata-soanydata-1_1_0" data
  [[ -d src/Inventor/Qt/common ]] || cp -r "${srcdir}/sogui-soqt-${pkgver//./_}" src/Inventor/Qt/common
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DSOQT_BUILD_TESTS=OFF \
    ../soqt-SoQt-${pkgver}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/soqt-SoQt-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}

# vim:set ts=2 sw=2 et:
